<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
	<style type="text/css">
		body, html{width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
		#allmap {height:500px; width: 100%;}
		#control{width:100%;}
	</style>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=6oe6aKGHbSrHcwiwkBG6OiTL"></script>
	<title>设置线、面可编辑</title>
</head>
<body>
	<div id="allmap"></div>
	<div id="control">
		<button onclick = "polyline.enableEditing();polygon.enableEditing();">开启线、面编辑功能</button>
		<button onclick = "polyline.disableEditing();polygon.disableEditing();">关闭线、面编辑功能</button>
	</div>
</body>
</html>
<script type="text/javascript">
	// 百度地图API功能
	var map = new BMap.Map("allmap");
	map.centerAndZoom(new BMap.Point(116.306358,40.049288), 15);
	map.enableScrollWheelZoom();

	var polyline = new BMap.Polyline([
		new BMap.Point(116.303000,40.049000),
		new BMap.Point(116.308358,40.040588),
		new BMap.Point(116.300358,40.047688),
		new BMap.Point(116.301358,40.049388)
	], {strokeColor:"red", strokeWeight:12, strokeOpacity:0.5});   //创建折线
	map.addOverlay(polyline);   //增加折线
	
	var polygon = new BMap.Polygon([
		new BMap.Point(116.3032,40.046977),
		new BMap.Point(116.305243,40.043063),
		new BMap.Point(116.304226,40.044988),
		new BMap.Point(116.401772,40.045364),
		new BMap.Point(116.40248,40.047893)
	], {strokeColor:"blue", strokeWeight:12, strokeOpacity:0.5});  //创建多边形
	map.addOverlay(polygon);   //增加多边形
	
	var polygon = new BMap.Polygon([
		new BMap.Point(116.387112,39.926977),
		new BMap.Point(116.385243,39.913063),
		new BMap.Point(116.394226,39.914988),
		new BMap.Point(116.401772,39.925364),
		new BMap.Point(116.41248,39.927893)
	], {strokeColor:"blue", strokeWeight:12, strokeOpacity:0.5});  //创建多边形
	map.addOverlay(polygon);   //增加多边形
</script>

